/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef MATHUTILS_H
#define MATHUTILS_H

#include <math.h>

//macros for converting angles between radians and degrees
#define DegToRad(x) (( x )*M_PI/180.0)
 
#define RadToDeg(x) (( x )*180.0/M_PI)

#define average(x, y) ((( x )+( y ))/2.0)

//takes a ODE-style rotation matrix and a position vector, resulting in 
//homogenous transform matrix M to use with OpenGL
void ODEToOGL(const float* R, const float* P, float* M);

//multiply 3x3 matrices M1*M2
void MxM3(const float* M1, const float* M2, float* result);

//multiply ode-style 3x3 matrices (dMatrix3) that actually are 3x4 matrices
void OdeMxM3(const float* M1, const float* M2, float* result);

//multiply 3d-vector V with 3x3 matrix M
void MxV3(const float* M,const float* V, float* result);

//takes ode-style rotation matrix and a vector and rotates that vector
void RotateVector(const float* R,const float* v, float* result);

//returns dot product of two 3d vectors
float DotProduct(const float *v1, const float *v2);

//calculates the cross product of two vectors
void CrossProduct(const float *v1, const float *v2, float* result);

//returns the length of vector
float VectorLength(const float *v);

#endif //MATHUTILS_H
